<template>
	<div class="page-wrap">
		<page-title></page-title>
		<div class="back">
			<el-button @click="goback" type="primary" size="small">返回</el-button>
		</div>
		<div class="page-content">
			<div class="page-row">
				<div class="box-right">
					<div class="table-box">
						<el-tabs v-model="activeTab" class="flex-tabs">
							<el-tab-pane name="1" label="湿沉降分析" lazy>
								<wetSedAnalyse
									ref="wet"
									:basicDataF="this.basicData"
									v-on:changeActiveTab="changeActive($event)"
								></wetSedAnalyse>
							</el-tab-pane>
							<!-- :disabled="this.showactiveTab < 2" -->
							<el-tab-pane name="2"  label="干沉降分析" lazy>
								<drySedAnalyse :basicDataF="this.basicData" v-on:changeActiveTab="changeActive($event)"></drySedAnalyse>
							</el-tab-pane>
							<!-- :disabled="this.showactiveTab < 3" -->
							<el-tab-pane name="3"  label="扩散参数分析" lazy>
								<diffAnalyse :basicDataF="this.basicData" v-on:changeActiveTab="changeActive($event)"></diffAnalyse>
							</el-tab-pane>
							<!-- :disabled="this.showactiveTab < 4" -->
							<el-tab-pane name="4"  label="烟团参数分析" lazy>
								<puffAnalyse :basicDataF="this.basicData" v-on:changeActiveTab="changeActive($event)"></puffAnalyse>
							</el-tab-pane>
							<!-- :disabled="this.showactiveTab < 5" -->
							<el-tab-pane name="5"  label="烟团释放分析" lazy>
								<puffReleaseAnalyse
									:basicDataF="this.basicData"
									v-on:changeActiveTab="changeActive($event)"
								></puffReleaseAnalyse>
							</el-tab-pane>
						</el-tabs>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
import wetSedAnalyse from "./wetSedAnalyse.vue"
import drySedAnalyse from "./drySedAnalyse.vue"
import diffAnalyse from "./diffAnalyse.vue"
import puffAnalyse from "./puffAnalyse.vue"
import puffReleaseAnalyse from "./puffReleaseAnalyse"
import { mapState } from "vuex"

export default {
	components: {
		wetSedAnalyse,
		drySedAnalyse,
		diffAnalyse,
		puffAnalyse,
		puffReleaseAnalyse,
	},
	data() {
		return {
			activeTab: "1",
			basicData: {
				GENUMRAD001: "",
				zaoqiList: [],
				aiZhengList: [],
				ISOTPGRP_NAM: [],
				MIORGDEF_ORG: [],
				PDPOPFLG001: "",
				OCENDAT1001: "",
				MIENDAT2001: "",
			},
		}
	},
	computed: {
		...mapState({
			showactiveTab: (state) => state.token.senstivity_show_Tab,
			basic_Data: (state) => state.token.basic_Data,
			senstivity_Data: (state) => state.token.senstivity_Data,
		}),
	},
	created() {
		// console.log(this.activeTab)
		// console.log(this.showactiveTab)
		this.getBasicData()
		this.initialize()
		this.$emit("changeActiveTab", this.activeTab)
		this.$store.dispatch("change_senstivity_showTab", this.activeTab)
		this.router()
	},
	methods: {
		//配置面包屑
		router() {
			// let temproute = [...this.$route.query.routeList]
			let temproute = []
			let advert = {
				resrName: "敏感度分析",
			}
			temproute.push(advert)
			this.$store.commit("updateRoute", temproute)
		},
		goback() {
			this.$router.go(-1)
		},

		getBasicData() {
			//获取早期模块数据
			let params = {
				batchid: this.$route.query.id,
				batchinfo: "BASE",
			}
			// console.log(params)
			this.$appApi
				.BATCH_DETAIL(params)
				.then((res) => {
					var str = res.data.substring(0, 1)
					if (str == "E") {
						let message = res.data.substring(6)
						this.$notify.error({
							title: "请求数据失败！",
							message: message,
							type: "success",
						})
					} else if (str == "S") {
						let tempdata = JSON.parse(res.data.substring(8))
						this.$store.dispatch(
						"change_senstivity_showTab",
						tempdata.SETPAGEINDEX
					)
						this.$store.dispatch("upData_basic_Data", tempdata) 
					}
				})
				.catch((err) => {
					console.log(err)
				})
		},
		initialize() {
			//敏感
			let params = {
				batchid: this.$route.query.id,
				batchinfo: "MINGAN",
			} 
			this.$appApi
				.BATCH_DETAIL(params)
				.then((res) => {
					var str = res.data.substring(0, 1)
					if (str == "E") {
						let message = res.data.substring(6)
						this.$notify.error({
							title: "请求数据失败！",
							message: message,
							type: "success",
						})
					} else if (str == "S") {
						let tempdata = JSON.parse(res.data.substring(8))
						tempdata.WDCWASH1Num = 0
						tempdata.WDCWASH2Num = 0
						tempdata.DDNPSGRPNum = 0
						tempdata.DPCYSIGANum = 0
						tempdata.DPCYSIGBNum = 0
						tempdata.DPCZSIGANum = 0
						tempdata.DPCZSIGBNum = 0
						tempdata.DPYSCALE001Num = 0
						tempdata.DPZSCALE001Num = 0
						tempdata.PMXPFAC1001Num = 0
						tempdata.PMXPFAC2001Num = 0
						tempdata.PRSCLCRW001Num = 0
						tempdata.PRSCLADP001Num = 0
						tempdata.PRSCLEFP001Num = 0
						tempdata.RDNUMRELNum = 0
						tempdata.RDRELFRC_VALUENum = 0

						this.$store.dispatch("upData_senstivity_Data", tempdata)
						this.$refs.wet.setData()
					}
				})
				.catch((err) => {
					console.log(err)
				})
		},
		changeActive(value) {
			// console.log(value)
			this.activeTab = value
		},
	},
}
</script>